/*
 * @Author: szx
 * @Date: 2021-10-22 14:14:05
 * @LastEditTime: 2021-10-22 14:19:19
 * @Description:
 * @FilePath: \leetcode\169\169.cpp
 */
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
class Solution {
   public:
    int majorityElement(vector<int>& nums) {
        int n = nums.size();
        unordered_map<int, int> map;
        for (auto& v : nums) {
            map[v]++;
        }
        for (auto& v : map) {
            if (v.second > n / 2) {
                return v.first;
            }
        }
        return 0;
    }
};

int main() {
    Solution s;
    vector<int> v = {3, 2, 3};
    cout << s.majorityElement(v) << endl;
    return 0;
}